package com.frejoys.common.config;

import com.frejoys.common.constant.CommonConstant;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.security.SecurityRequirement;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.List;

@Configuration
public class SpringDocConfig {

    /**
     * app接口分组
     * @return
     */
    @Bean
    public GroupedOpenApi appGroup() {
        return GroupedOpenApi.builder().group("app").displayName("App接口").addOpenApiCustomizer(openApi -> openApi.info(new Info().title("用户App接口").version("1.0")).security(List.of(new SecurityRequirement().addList(CommonConstant.authorization)))).pathsToMatch("/app/**").build();
    }

    /**
     * admin后台接口分组
     * @return
     */
    @Bean
    public GroupedOpenApi adminGroup() {
        return GroupedOpenApi.builder().group("admin").displayName("Admin后台接口").addOpenApiCustomizer(openApi -> openApi.info(new Info().title("管理Admin后台接口").version("1.0")).security(List.of(new SecurityRequirement().addList(CommonConstant.authorization)))).pathsToMatch("/admin/**").build();
    }

    /**
     * open接口分组
     * @return
     */
    // @Bean
    // public GroupedOpenApi openGroup() {
    //     return GroupedOpenApi.builder().group("open").displayName("Open接口").addOpenApiCustomizer(openApi -> openApi.info(new Info().title("Open接口").version("1.0")).security(List.of(new SecurityRequirement().addList(CommonConstant.authorization)))).pathsToMatch("/open/**").build();
    // }


    /**
     * store接口分组
     * @return
     */
    @Bean
    public GroupedOpenApi storeGroup() {
        return GroupedOpenApi.builder().group("store").displayName("Store接口").addOpenApiCustomizer(openApi -> openApi.info(new Info().title("商家Store接口").version("1.0")).security(List.of(new SecurityRequirement().addList(CommonConstant.authorization)))).pathsToMatch("/store/**").build();
    }

}
